import { ResponseInterceptor } from './../../../interceptor/response/response.interceptor';
import { AdminService } from './../../../service/admin/admin.service';
import { Body, Controller, Delete, Get, Patch, Post, UseInterceptors } from '@nestjs/common';
import config from '../../../config/config';

@Controller(`${config.adminPath}/manager`)
@UseInterceptors(ResponseInterceptor)
export class ManagerController {
    constructor(private readonly adminService: AdminService) {}
    @Get()
    async find() {
        return await this.adminService
            .getModel()
            .aggregate([{ $lookup: { from: 'role', localField: 'role_id', foreignField: '_id', as: 'role' } }]);
    }
    @Post()
    async create(@Body() body) {
        return await this.adminService.create(body);
    }
    @Patch()
    async update(@Body() body) {
        return await this.adminService.update(body);
    }
    @Delete()
    async delete(@Body() body) {
        return await this.adminService.delete(body);
    }
}
